Repository navigation
feat: map Markdown YAML front matter to content properties - #273
Merged
Merged
Conversation
- Add opt-in --front-matter to create, create-child, and update
(markdown only): the "properties" map is stripped from the body and
applied as content properties after the page is saved
- Parse and validate front matter before any network call; unlisted
properties are left untouched and matching values are skipped, so
re-running after a partial failure is safe
- Report property failures after the body is saved and exit non-zero;
--json includes properties { applied, unchanged, failed } on stdout
and a PARTIAL_FAILURE error on stderr
- Add read --format markdown --front-matter <keys> to export the listed
properties that exist, in the given order
- Add js-yaml as a direct dependency
Closes #260
- Point create/create-child partial failures at the update command that retries the properties, instead of re-running create - Include the Confluence error message in failed property entries - Reject --front-matter with --type folder, accept an empty file, and only refuse an empty body when the document actually has front matter - Warn when front matter has no "properties" map - Keep the requested key order on read for integer-like keys - Document content-appearance-draft alongside the published key
|
🎉 This PR is included in version 2.28.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #260
Problem
Content properties such as page width (
content-appearance-published) can only be changed one page at a time withproperty-set. Users who keep pages as Markdown files want to keep selected properties in each file, change them with search and replace, review the change in git, and apply it through the normal upload workflow.Changes
Writes (
create,create-child,update)New opt-in
--front-matterflag, valid only with--format markdown. Without it, a leading---stays part of the body (a thematic break), exactly as today.Only the
propertiesmap is applied; other top-level keys are ignored:Front matter is parsed and validated before any network call, so invalid YAML uploads nothing.
create-childnow resolves the parent page after this check.Properties not listed are left untouched. A property whose stored value already matches (deep equality) is not rewritten.
A block without a
propertiesmap prints a warning.--front-matteris rejected with--type folder.A document without front matter is uploaded as-is and sets no properties.
Partial failure
--json, stdout carries the usual result plusproperties: { applied, unchanged, failed }, and stderr carries an error with codePARTIAL_FAILUREand the samepropertiesindetails.updateis safe: properties that already match are skipped. Forcreateandcreate-child, the error names theupdate ... --front-mattercommand that retries the properties on the new page, since re-runningcreatewould try to make another page.Reads
read --format markdown --front-matter key1,key2prepends the listed properties that exist, in the given order. Missing keys are omitted. If none exist, no block is emitted, unless the body itself starts with---; then an emptyproperties: {}block is emitted so a later--front-matterupload cannot mistake the body for front matter.content-appearance-draft, so both keys should be set for page width.Guards
update --front-matterwith a document that has front matter but no body is refused instead of emptying the page. Blank content without front matter behaves as it does without the flag. Useproperty-setto change only properties.key:(top-levelnull) is rejected as a likely mistake. Nulls nested inside a value are kept, so existing JSON properties round-trip.2026-10-05stays a string instead of becoming a date. On output, date-like strings are quoted.Dependency
js-yamlbecomes a direct dependency. The top-level override now uses"$js-yaml", because an override that differs from a direct dependency spec makesnpm packfail withEOVERRIDE.js-yamlandargparseare included in the generated production shrinkwrap.Not included
exportdoes not emit front matter yet.--front-matter.Testing
tests/front-matter.test.js: parsing (no front matter, CRLF, BOM,...closing, ignored keys, empty block, later thematic breaks, nested nulls, dates), rejections (unterminated, invalid YAML, non-mapping root orproperties, bare null, non-finite numbers), serialization order and round trip, the thematic-break guard, and key list parsing.tests/confluence-client.test.js:syncPropertiescreates missing keys, increments the version of changed keys, skips matching keys, and keeps going after a failure;getPropertyValueskeeps the requested order, omits 404s, and propagates other errors.tests/front-matter-cli.test.js: body stripping and property application for all three write commands, pass-through without the flag, validation before any network call, the--format markdownand body requirements, the empty-body guard, text and--jsonpartial failure output,readoutput, and aread→updateround trip.npm test(1812 tests) andnpm run lintpass.read --front-matter→update --front-matterreproduced the same storage body and left matching properties untouched, and invalid front matter made no HTTP requests.